#include "window.h"

#include <GL/glew.h>

void CWindow::SetParams(int Width, int Height, int Bpp, Uint32 Flags)
{
	nWidth = Width;
	nHeight = Height;
	nBpp = Bpp;

	uFlags = Flags;
}

void CWindow::Create(int Width, int Height, int Bpp, Uint32 Flags)
{
	nWidth = Width;
	nHeight = Height;
	nBpp = Bpp;
	uFlags = Flags;

	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	Screen = SDL_SetVideoMode(nWidth, nHeight, nBpp, uFlags);
	SDL_Flip(Screen);

	glewInit();

	bCreated = true;
}

void CWindow::Create()
{
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	Screen = SDL_SetVideoMode(nWidth, nHeight, nBpp, uFlags);
	SDL_Flip(Screen);

	glewInit();

	bCreated = true;
}

bool CWindow::Created()
{
	return bCreated;
}

void CWindow::Resize(int Width, int Height)
{
	nWidth = Width;
	nHeight = Height;
}
